package com.ruoyi.labdata.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.labdata.domain.LabGasCylindersType;
import com.ruoyi.labdata.domain.LabRestrictedKinds;
import com.ruoyi.labdata.service.ILabGasCylindersTypeService;
import com.ruoyi.labdata.service.ILabRestrictedKindsService;

/**
 * 气瓶名录Controller
 * 
 * @author winner pan
 * @date 2022-02-16
 */
@RestController
@RequestMapping("/labdata/cylindersType")
public class LabGasCylindersTypeController extends BaseController
{
    @Autowired
    private ILabGasCylindersTypeService labGasCylindersTypeService;
    
    @Autowired
    private ILabRestrictedKindsService labRestrictedKindsService;
    
   //labRestrictedPropertyService
    @GetMapping(value = "/allRestrictedKinds")
    public AjaxResult getAllRestrictedKinds(){
    	LabRestrictedKinds labRestrictedKinds = new LabRestrictedKinds();
    	labRestrictedKinds.setStatusOpt(Long.valueOf(1));
        return AjaxResult.success(labRestrictedKindsService.selectLabRestrictedKindsList(labRestrictedKinds));
    }

    /**
     * 查询气瓶名录列表
     * 公共资源不设访问权限
     */
    //@PreAuthorize("@ss.hasPermi('labdata:cylindersType:query')")
    @GetMapping("/list")
    public TableDataInfo list(LabGasCylindersType labGasCylindersType)
    {
        startPage();
        List<LabGasCylindersType> list = labGasCylindersTypeService.selectLabGasCylindersTypeList(labGasCylindersType);
        return getDataTable(list);
    }

    /**
     * 导出气瓶名录列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:cylindersType:export')")
   /* @Log(title = "气瓶名录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabGasCylindersType labGasCylindersType)
    {
        List<LabGasCylindersType> list = labGasCylindersTypeService.selectLabGasCylindersTypeList(labGasCylindersType);
        ExcelUtil<LabGasCylindersType> util = new ExcelUtil<LabGasCylindersType>(LabGasCylindersType.class);
        return util.exportExcel(list, "cylindersType");
    }*/

    /**
     * 获取气瓶名录详细信息
     */
    @PreAuthorize("@ss.hasPermi('labdata:cylindersType:query')")
    @GetMapping(value = "/{cylindersType}")
    public AjaxResult getInfo(@PathVariable("cylindersType") Long cylindersType)
    {
        return AjaxResult.success(labGasCylindersTypeService.selectLabGasCylindersTypeById(cylindersType));
    }

    /**
     * 新增气瓶名录
     */
    @PreAuthorize("@ss.hasPermi('labdata:cylindersType:edit')")
    @Log(title = "气瓶名录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabGasCylindersType labGasCylindersType)
    {
        return toAjax(labGasCylindersTypeService.insertLabGasCylindersType(labGasCylindersType));
    }

    /**
     * 修改气瓶名录
     */
    @PreAuthorize("@ss.hasPermi('labdata:cylindersType:edit')")
    @Log(title = "气瓶名录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabGasCylindersType labGasCylindersType)
    {
        return toAjax(labGasCylindersTypeService.updateLabGasCylindersType(labGasCylindersType));
    }

    /**
     * 删除气瓶名录
     */
    @PreAuthorize("@ss.hasPermi('labdata:cylindersType:edit')")
    @Log(title = "气瓶名录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cylindersTypes}")
    public AjaxResult remove(@PathVariable Long[] cylindersTypes)
    {
        return toAjax(labGasCylindersTypeService.deleteLabGasCylindersTypeByIds(cylindersTypes));
    }
}
